<?php
	session_start();
	require('include/inc.start.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Thanks for registering!</title>
<?php include ('common_head.html');?>
<link href="css/register.css" rel="stylesheet" type="text/css" />

</head>

<body>
<?php include ('login.php');?>
<div class="back">	
  <div class="footerBg">
  <div id="frame">
  <?php include ('header.php');?>
  <div class="mainfrm">
  <div class="bluestripfrm">
  <div class="regthanks">
  <h1>Your account has been activated!</h1>
  </div>
  </div><!--bluestripfrm-->
<div id="confirm">
	<h1> What's next?</h1>
    <div class="space"></div>
	     <?php
	 
	 // initially bad code, that will give no result, if right code is not sent
	 $code = "~~~~~~~~~~~~~~~~~~~";
	if (!isset($_GET['code'])){
	 echo "<p style='color: #DB2929'>*IMPORTANT: We're sorry, something went wrong. Please contact support@getub.com and provide your e-mail address so we can manually activate your account.</p><br />";	
	} else{
	  $code = $_GET['code'];
	  
	  // connection settings stored in file
	include("connectionParameters.php");
	
   $connection = mysql_connect($host,$user,$pass)
		or die ("<p style='color: #DB2929'>*IMPORTANT: There seems to be a problem. Please send an e-mail to support@getub.com and mention error code 499.</p><br />");

	mysql_select_db($database);

	//we need to get user id to update user profile
	$q = 'SELECT `userId` FROM `Activation` WHERE `userCode`="' . $code . '" LIMIT 1';
	$result = mysql_query($sql);
	$row = mysql_fetch_array($result);
	if (mysql_num_rows($result) > 0 && $row['userId'] > 0) {
		//set user profile state to active
		mysql_query('UPDATE `Users` SET active = 1 WHERE `userId` = ' . $row['userId'] . ' LIMIT 1');
	}
	 
	 $result = mysql_query($query,$connection)
		or die ("<p style='color: #DB2929'>*IMPORTANT: We're sorry, something went wrong. Please contact support@getub.com and provide your e-mail address so we can manually activate your account.</p><br />");
	echo ("<p>You can now login using the email and password you used during registration.</p><div class='space'></div>");
	}
	 ?>
     
    <p>Once logged in, you can search for books on the <a href="buyBooks.php"> buy books page</a> or sell your textbooks on <a href="sellBooks.php">this page</a> page.</p>
     <div class="space"></div>
    <p>You can also search or post an ad on the <a href="roommates.php">roommates page</a> if you're looking for roomies.</p>
    
    </div>
  <?php include("footer.php"); ?>
</div><!--mainfrm -->
   </div><!--frame-->
 </div><!--footerBg-->
</div><!--back -->
</body>
</html>